#!/bin/bash
# Script for creating a new release image of the Judge0 API.
# 
# Usage: ./scripts/dev/tag
#
set -xe

image=judge0/api
commit_hash="$(git log -1 --format=%h --abbrev=8)"
commit_tag="$(git tag --points-at HEAD)"

if [[ $commit_tag == "" ]]; then
    echo "No tag for current commit."
    exit -1
fi

./scripts/dev/build

commit_tag=${commit_tag:1} # Drop the "v" at the beginning.

docker tag $image:$commit_hash $image:$commit_tag
docker tag $image:$commit_hash $image:latest

docker tag $image:$commit_hash-dev $image:$commit_tag-dev
docker tag $image:$commit_hash-dev $image:latest-dev
